
def reverse(self, x: int) -> int:
    s = str(x)
    sign = ""
    if s[0] == '-':
        sign = s[0]
        s = s[1:]
    s = s[::-1]
    s = s[1:] if s[0] == "0" else s
    s = sign + s if sign != "" else s
    i32 = 0
    try:
        i32 = int(s)
        if i32 < -2147483648 or i32 > 2147483647:
            i32 = 0
    except Exception as e:
        print(e.args)
    return i32
